(function(){var t=window.BX;var a=function(){var a=function(a,i){this.node=a;this.tabs={};this.repo=[];if(t.type.isArray(i)){var s,e;while((s=i.shift())&&s){if(this.add(s))e=s}this.show(e)}};a.prototype={add:function(a){var i,s;i=t.findChild(this.node,{attribute:{"data-bx-role":"tab-"+a}},true);s=t.findChild(this.node,{attribute:{"data-bx-role":"tab-"+a+"-body"}},true);if(i&&s){this.tabs[a]={head:i,body:s};t.bind(i,"click",t.proxy(function(){this.show(a)},this));return true}return false},show:function(a,i){if(this.tabs.hasOwnProperty(a)){var s="";for(var e in this.tabs){if(this.tabs.hasOwnProperty(e)){if(this.tabs[e]["head"].hasAttribute("active"))s=e;if(e!==a){this.tabs[e]["head"].removeAttribute("active");if(!i||i!==e)t.removeClass(this.tabs[e]["head"],"main-file-input-tab-button-active");t.hide(this.tabs[e]["body"])}}}this.tabs[a]["head"].setAttribute("active","Y");t.addClass(this.tabs[a]["head"],"main-file-input-tab-button-active");if(i&&this.tabs[i])t.addClass(this.tabs[i]["head"],"main-file-input-tab-button-active");t.show(this.tabs[a]["body"]);if(s!==a){t.onCustomEvent(this,"onTabHasBeenChanged",[a,s,this]);this.repo.push(i||a)}}},showPrevious:function(){this.repo.pop();var t=this.repo.pop();if(t)this.show(t)},getActive:function(){var a="";for(var i in this.tabs){if(this.tabs.hasOwnProperty(i)){if(t.hasClass(this.tabs[i]["head"],"main-file-input-tab-button-active")){a=i;break}}}return a}};return a}(),i=null,s=function(){var a=function(a){this.scale=a.scale;this.knob=a.knob;this.minus=a.minus;this.plus=a.plus;this.moveKnob=null;t.bind(this.minus,"click",t.proxy(this.decrease,this));t.bind(this.plus,"click",t.proxy(this.increase,this));t.bind(this.knob,"mousedown",t.proxy(this.startMoving,this));this.move=t.delegate(this.move,this);this.stopMoving=t.delegate(this.stopMoving,this)};a.prototype={step:.1,init:function(){},bind:function(){},reset:function(){this.move()},increase:function(){this.move(true)},decrease:function(){this.move(false)},startMoving:function(){t.bind(document,"mousemove",this.move);t.bind(document,"mouseup",this.stopMoving)},move:function(a){var i={x:0,percent:0},s,e;if(a===true||a===false){var n=parseFloat(this.knob.getAttribute("data-bx-percent"));if(!(n>0))n=0;n+=(a===true?1:-1)*this.step;if(!this.moveKnob2){s=t.pos(this.scale);e=t.pos(this.knob);this.moveKnob2=function(t){var a=Math.min(Math.max(t,0),1);return{x:Math.ceil((s["width"]-e["width"])*a),percent:a}}}i=this.moveKnob2(n)}else if(a){if(!this.moveKnob){s=t.pos(this.scale);e=t.pos(this.knob);this.moveKnob=function(t){var a=Math.min(Math.max(t-s["left"],0),s["width"]-e["width"]);return{x:Math.ceil(a),percent:a/Math.max(s["width"]-e["width"],1)}}}t.fixEventPageXY(a);i=this.moveKnob(a.pageX)}t.adjust(this.knob,{style:{left:i.x+"px"},attrs:{"data-bx-percent":i.percent}});t.onCustomEvent(this,"onChangeSize",[i.percent])},stopMoving:function(){t.unbind(document,"mousemove",this.move);t.unbind(document,"mouseup",this.stopMoving)}};return a}(),e={},n=function(){if(!e["canvasConstructor"])e["canvasConstructor"]=new t.UploaderFileCnvConstr;return e["canvasConstructor"]}(),o=function(){var a=function(a){if(!t(a))throw"BX.canvasEditor: Canvas is not a DOM node.";this.canvas=a;this.ctx=this.canvas.getContext("2d");this.canvasBlock=a.parentNode;this.params={scaleMultiplier:1,visibleWidth:a.width>0?a.width:1,visibleHeight:a.height>0?a.height:1,width:a.width,height:a.height};this.startMoving=t.delegate(this.startMoving,this);this.move=t.delegate(this.move,this);this.stopMoving=t.delegate(this.stopMoving,this);this.reset()};a.prototype={reset:function(){this.canvasIsSet=false;this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.disableToMove();this.canvas.style.cursor="default";t.onCustomEvent(this,"onResetCanvas",[this.canvas])},set:function(a){var i,s,e;if(a.clientWidth){i=a.clientWidth;s=a.clientHeight}else{var n=t.UploaderUtils.scaleImage(a,{width:1024,height:1024});i=n.destin.width;s=n.destin.height}if(a["name"])this.params.name=a["name"];else delete this.params["name"];e=Math.ceil(Math.max(i>0?this.params.visibleWidth/i:1,s>0?this.params.visibleHeight/s:1)*100)/100;this.params.scale=0<e&&e<1?e:1;this.params.width=i;this.params.height=s;delete this.params.left;delete this.params.top;delete this.params.zeroLeft;delete this.params.zeroTop;delete this.params.overWidth;delete this.params.overHeight;this.cursor=null;this.params.zoomScale=1;t.adjust(this.canvas,{props:{width:this.params.width,height:this.params.height}});this.ctx.drawImage(a,0,0,this.canvas.width,this.canvas.height);this.canvasIsSet=true;this.calculateOffsets({});this.params.firstScale=this.params.zoomScale;this.params.firstLeft=this.params.left;this.params.firstTop=this.params.top;t.onCustomEvent(this,"onChangeCanvas",[this.canvas,{width:this.params.width,height:this.params.height,left:(this.params.left-this.params.zeroLeft)/this.params.scale,top:(this.params.top-this.params.zeroTop)/this.params.scale,scale:this.params.zoomScale,maxScale:1+(1-this.params.scale)/this.params.scale}])},load:function(a){if(!this.onLoadFile){this.onLoadFile=t.delegate(this.set,this)}if(!this.onLoadingFileIsFailed){this.onLoadingFileIsFailed=t.delegate(function(){this.showError(t.message("JS_AVATAR_EDITOR_ERROR_IMAGE_DEPLOYING"),arguments)},this)}this.reset();n.push(a,this.onLoadFile,this.onLoadingFileIsFailed)},showError:function(a,i){t.onCustomEvent(this,"onErrorCanvas",[a,i])},scale:function(a){if(this.params.scale<1){this.calculateOffsets({zoomScale:1+(1-this.params.scale)*a/this.params.scale});t.onCustomEvent(this,"onChangeCanvasArea",[{left:(this.params.left-this.params.zeroLeft)/this.params.scale,top:(this.params.top-this.params.zeroTop)/this.params.scale,scale:this.params.zoomScale}])}},calculateOffsets:function(a){var i=this.params.zeroLeft,s=this.params.zeroTop,e=this.params.zoomScale;if(a["zoomScale"])this.params.zoomScale=Math.ceil(a.zoomScale*100)/100;this.params.zeroLeft=(this.params.width*this.params.scale*this.params.zoomScale-this.params.width)/2;this.params.zeroTop=(this.params.height*this.params.scale*this.params.zoomScale-this.params.height)/2;this.params.overWidth=(this.params.width*this.params.scale*this.params.zoomScale-this.params.visibleWidth)/2;this.params.overHeight=(this.params.height*this.params.scale*this.params.zoomScale-this.params.visibleHeight)/2;if(a["zoomScale"]){var n=this.params.zeroLeft+(this.params.left-i-this.params.visibleWidth/2)/e*this.params.zoomScale+this.params.visibleWidth/2,o=this.params.zeroTop+(this.params.top-this.params.visibleHeight/2-s)/e*this.params.zoomScale+this.params.visibleHeight/2;this.params.left=this.params.zeroLeft-this.params.overWidth;if(this.params.overWidth>0)this.params.left=Math.min(this.params.zeroLeft,Math.max(this.params.zeroLeft-this.params.overWidth*2,n));this.params.top=this.params.zeroTop-this.params.overHeight;if(this.params.overHeight>0)this.params.top=Math.min(this.params.zeroTop,Math.max(this.params.zeroTop-this.params.overHeight*2,o))}else{this.params.left=this.params.zeroLeft-this.params.overWidth;this.params.top=this.params.zeroTop-this.params.overHeight}var r;if(this.params.overWidth>0||this.params.overHeight>0){r="move";this.enableToMove()}else{r="default";this.disableToMove()}this.canvas.style.cursor=r;t.adjust(t(this.canvasBlock),{style:{width:this.params.width+"px",height:this.params.height+"px",transform:"translate("+Math.ceil(this.params.left)+"px, "+Math.ceil(this.params.top)+"px) scale("+this.params.scale*this.params.zoomScale+", "+this.params.scale*this.params.zoomScale+")"}})},enableToMove:function(){t.bind(this.canvasBlock,"mousedown",this.startMoving)},disableToMove:function(){t.unbindAll(this.canvasBlock)},startMoving:function(a){t.fixEventPageXY(a);this.cursor={pageX:a.pageX,pageY:a.pageY};t.bind(document,"mousemove",this.move);t.bind(document,"mouseup",this.stopMoving)},move:function(a){if(this.cursor!==null){t.fixEventPageXY(a);if(this.params.overWidth>0){this.params.left=Math.min(this.params.zeroLeft,Math.max(this.params.zeroLeft-this.params.overWidth*2,this.params.left+a.pageX-this.cursor.pageX));this.cursor.pageX=a.pageX}if(this.params.overHeight>0){this.params.top=Math.min(this.params.zeroTop,Math.max(this.params.zeroTop-this.params.overHeight*2,this.params.top+a.pageY-this.cursor.pageY));this.cursor.pageY=a.pageY}t.adjust(this.canvasBlock,{style:{transform:"translate("+Math.ceil(this.params.left)+"px, "+Math.ceil(this.params.top)+"px) scale("+this.params.scale*this.params.zoomScale+", "+this.params.scale*this.params.zoomScale+")"}});t.onCustomEvent(this,"onChangeCanvasArea",[{left:(this.params.left-this.params.zeroLeft)/this.params.scale,top:(this.params.top-this.params.zeroTop)/this.params.scale,scale:this.params.zoomScale}])}},stopMoving:function(){t.unbind(document,"mousemove",this.move);t.unbind(document,"mouseup",this.stopMoving)},pack:function(){var a=null;if(this.canvasIsSet){if(this.params.firstScale===this.params.zoomScale&&this.params.firstLeft===this.params.left&&this.params.firstTop===this.params.top){a=t.UploaderUtils.dataURLToBlob(this.canvas.toDataURL("image/png"));a.changed=false}else{var i=this.params.zoomScale*this.params.scale,s=Math.ceil((this.params.left-this.params.zeroLeft)/i),e=Math.ceil((this.params.top-this.params.zeroTop)/i),o=Math.ceil(this.params.visibleWidth/i),r=Math.ceil(this.params.visibleHeight/i);if(s>0){o-=s;s=0}if(e>0){r-=e;e=0}if(o<=0||r<=0)throw"BX.canvasEditor: width or height is undefined.";t.adjust(n.getCanvas(),{props:{width:o,height:r}});n.getContext().drawImage(this.canvas,Math.abs(s),Math.abs(e),o,r,0,0,o,r);a=n.pack();a.changed=true}if(this.params["name"])a.name=this.params["name"];if(a.type==="image/png"&&(a.name||"").substr(-4,4).toLowerCase()!==".png"){var h=a.name||"image";if(h.lastIndexOf(".")>0&&t.UploaderUtils.isImageExt(h.substr(h.lastIndexOf(".")+1).toLowerCase())){a.name=h.substr(0,h.lastIndexOf("."))}a.name=a.name+".png"}}return a}};return a}(),r=function(){var a=function(a){if(!t(a))throw"Canvas is not a DOM node.";this.canvas=a;this.ctx=this.canvas.getContext("2d");this.canvasBlock=a.parentNode;this.params={scaleMultiplier:2,visibleWidth:a.width>0?a.width:1,visibleHeight:a.height>0?a.height:1,width:a.width,height:a.height}};a.prototype={set:function(a,i){var s=i.width,e=i.height,n={width:this.params.visibleWidth,height:this.params.visibleHeight},o=Math.max(s>0?n.width*i.maxScale/s:1,e>0?n.height*i.maxScale/e:1);this.params.scaleMultiplier=i.maxScale;if(o>1){o=Math.max(s>0?n.width/s:1,e>0?n.height/e:1);this.params.scaleMultiplier=1}o=0<o&&o<1?o:1;this.params.width=s*o;this.params.height=e*o;this.params.scale=o;this.position({scale:1});t.adjust(this.canvas,{props:{width:this.params.width,height:this.params.height}});this.ctx.drawImage(a,0,0,this.canvas.width,this.canvas.height)},position:function(a){this.params.zoomScale=a.scale;this.params.overWidth=(this.params.width*this.params.zoomScale-this.params.visibleWidth)/2;this.params.overHeight=(this.params.height*this.params.zoomScale-this.params.visibleHeight)/2;this.params.zeroLeft=(this.params.width*this.params.zoomScale/this.params.scaleMultiplier-this.params.width)/2;this.params.zeroTop=(this.params.height*this.params.zoomScale/this.params.scaleMultiplier-this.params.height)/2;this.params.left=this.params.zeroLeft-this.params.overWidth;if(this.params.overWidth>0)this.params.left=a.left*this.params.scale/this.params.scaleMultiplier+this.params.zeroLeft;this.params.top=this.params.zeroTop-this.params.overHeight;if(this.params.overHeight>0)this.params.top=a.top*this.params.scale/this.params.scaleMultiplier+this.params.zeroTop;t.adjust(this.canvasBlock,{style:{width:this.params.width+"px",height:this.params.height+"px",transform:"translate("+Math.ceil(this.params.left)+"px, "+Math.ceil(this.params.top)+"px) scale("+this.params.zoomScale/this.params.scaleMultiplier+", "+this.params.zoomScale/this.params.scaleMultiplier+")"}})},reset:function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}};return a}();t.AvatarEditor=function(){var e;var n=function(a){this.id="avatarEditor"+(new Date).valueOf();this.popup=null;this.handlers={apply:t.delegate(this.apply,this),cancel:t.delegate(this.cancel,this),onPopupShow:t.delegate(this.onPopupShow,this),onAfterPopupShow:t.delegate(this.onAfterPopupShow,this),onPopupClose:t.delegate(this.onPopupClose,this)};a=t.type.isPlainObject(a)?a:{};this.params={enableCamera:a["enableCamera"]!==false};this.limitations=[]};n.prototype={isCameraEnabled:function(){var a=false;if(this.params.enableCamera===true){if(i===null&&t["webrtc"])i=new t.webrtc;a=window.location.protocol.indexOf("https")===0&&i&&i.enabled}return a},getLimitText:function(){return""},getTemplate:function(){var a=[],i=[];i.push('<span class="main-file-input-tab-button-item" data-bx-role="tab-canvas" style="display:none;">Canvas</span>');a.push(['<div class="main-file-input-content-block main-file-input-canvas-block" data-bx-role="tab-canvas-body" style="display: none;">','<div class="main-file-input-control">','<div class="main-file-input-control-controller" data-bx-role="zoom-minus-button">','<span class="main-file-input-control-minus"></span>',"</div>",'<div class="main-file-input-control-inner" data-bx-role="zoom-scale">','<div class="main-file-input-control-slide-container main-file-input-control-slide-drag-state">','<div class="main-file-input-control-slide" data-bx-role="zoom-knob"></div>',"</div>","</div>",'<div class="main-file-input-control-controller" data-bx-role="zoom-plus-button">','<span class="main-file-input-control-plus"></span>',"</div>","</div>",'<div class="main-file-input-camera-block-image">','<div class="main-file-input-user-loader-item">','<div class="main-file-input-loader">','<svg class="main-file-input-circular" viewBox="25 25 50 50">','<circle class="main-file-input-path" cx="50" cy="50" r="20" fill="none" stroke-width="1" stroke-miterlimit="10"></circle>',"</svg>","</div>","</div>",'<div class="main-file-input-error">',"<span>",t.message("JS_AVATAR_EDITOR_ERROR"),"</span>",'<span data-bx-role="tab-canvas-error"></span>',"</div>","<div>",'<canvas data-bx-canvas="canvas" height="330" width="330"></canvas>',"</div>","</div>",'<div class="main-file-input-button-layout">','<div class="main-file-input-button" data-bx-role="try-again-button">','<span class="main-file-input-button-icon"></span>','<span class="main-file-input-button-name">',t.message("JS_AVATAR_EDITOR_TRY_AGAIN"),"</span>","</div>","</div>","</div>"].join(""));i.push('<span class="main-file-input-tab-button-item'+(window.location.protocol.indexOf("https")===0?"":" main-file-input-tab-button-active")+'" data-bx-role="tab-file">'+t.message("JS_AVATAR_EDITOR_FILE")+"</span>");a.push(['<div class="main-file-input-content-block main-file-input-upload-block" data-bx-role="tab-file-body" ',window.location.protocol.indexOf("https")===0?' style="display: none;" ':"",">",'<div class="main-file-input-upload-link-container">','<label for="file',this.id,'" class="main-file-input-upload-link" for="file',this.id,'">',t.message("JS_AVATAR_EDITOR_PICK_UP_THE_FILE"),'<input type="file" id="file',this.id,'" data-bx-role="file-button" accept="image/*" />',"</label>",'<div class="main-file-input-upload-desc">',t.message("JS_AVATAR_EDITOR_DROP_FILES_INTO_THIS_AREA"),"</div>","</div>",'<div class="main-file-input-upload-info">','<div class="main-file-input-upload-info-item">',this.getLimitText(),"</div>","</div>","</div>"].join(""));if(this.isCameraEnabled()){i.push('<span class="main-file-input-tab-button-item main-file-input-tab-button-active" data-bx-role="tab-camera">'+t.message("JS_AVATAR_EDITOR_CAMERA")+"</span>");a.push(['<div class="main-file-input-content-block main-file-input-camera-block" data-bx-role="tab-camera-body">','<div class="main-file-input-camera-block-image">','<div class="main-file-input-user-loader-item">','<div class="main-file-input-loader">','<svg class="main-file-input-circular" viewBox="25 25 50 50">','<circle class="main-file-input-path" cx="50" cy="50" r="20" fill="none" stroke-width="1" stroke-miterlimit="10"/>',"</svg>","</div>","</div>",'<div class="main-file-input-error">',"<span>",t.message("JS_AVATAR_EDITOR_ERROR"),"</span>",'<span data-bx-role="tab-camera-error"></span>',"</div>",'<div class="main-file-input-camera-block-image-inner">',"<video autoplay></video>","</div>","</div>",'<div class="main-file-input-button-layout" data-bx-role="camera-button">','<div class="main-file-input-button">','<span class="main-file-input-button-icon"></span>',"</div>","</div>","</div>"].join(""))}var s=['<div class="main-file-input-tab-wrapper">','<div class="main-file-input-tab-button-container"',i.length<=2?' style="display: none"':"",">",i.join(""),"</div>",'<div class="main-file-input-tab-container">',a.join(""),'<div class="main-file-input-tab-avatar-block">','<div class="main-file-input-tab-avatar-inner">','<div class="main-file-input-arrow-icon-container">','<span class="main-file-input-arrow-icon"></span>',"</div>",'<div class="main-file-input-tab-avatar-image-container">','<span class="main-file-input-tab-avatar-image-item" data-bx-role="canvas-button">',"<div>",'<canvas data-bx-canvas="preview" height="136" width="136"></canvas>',"</div>","</span>","</div>",'<div class="main-file-input-tab-avatar-desc-container">','<span class="main-file-input-tab-avatar-desc-item">',"</span>","</div>","</div>","</div>","</div>","</div>"].join("");return s.replace(/#id#/gi,this.id)},onTabHasBeenChanged:function(a,i,s){var n=t(this.id);e=t.findChild(n,{tagName:"VIDEO"},true);if(s.tabs[a])t.removeClass(s.tabs[a]["body"],"errored");if(t(e)){if(a==="camera"&&e.getAttribute("active")!=="Y"){if(!e.hasAttribute("data-bx-bound")){e.setAttribute("data-bx-bound","Y");var o=e.parentNode.clientWidth,r=e.parentNode.clientHeight;e.addEventListener("playing",function(){var a=e.clientWidth,i=e.clientHeight,s=Math.max(a>0?o/a:1,i>0?r/i:1),n=(a*s-a)/2+(o-a*s)/2,h=(i*s-i)/2+(r-i*s)/2;t.adjust(e.parentNode,{style:{width:a+"px",height:i+"px",transform:"translate("+Math.ceil(n)+"px, "+Math.ceil(h)+"px) scale("+s+", "+s+")"}})})}e.setAttribute("active","Y");navigator.mediaDevices.getUserMedia({audio:false,video:{width:{max:1024,min:640,ideal:1024},height:{max:860,min:480,ideal:860}}}).then(function(t){if(e.hasAttribute("active")){e.srcObject=t}else{t.getTracks()[0].stop()}}).catch(function(i){if(s.tabs[a])t.addClass(s.tabs[a]["body"],"errored");var e=t.findChild(n,{attribute:{"data-bx-role":"tab-camera-error"}},true);if(e)e.innerHTML=i})}else if(e.getAttribute("active")==="Y"){e.removeAttribute("active");e.pause();e.src="";if(e.srcObject){e.srcObject.getTracks()[0].stop()}}}},addFiles:function(a){if(!t.type.isArray(a)){var i=[];for(var s=0;s<a.length;s++){i.push(a[s])}a=i}var e;var n=t.findChild(t(this.id),{tagName:"DIV",className:"main-file-input-user-loader-item"},true);if((e=a.pop())&&e&&this.canvas&&t.UploaderUtils.isImage(e.name,e.type,e.size)){this.canvas.load(e);this.tabs.show("canvas","file");t.hide(n)}else{t.show(n)}},bindTemplate:function(){var i=t(this.id);this.tabs=new a(i,["canvas","file","camera"]);t.addCustomEvent(this.tabs,"onTabHasBeenChanged",t.delegate(this.onTabHasBeenChanged,this));this.onTabHasBeenChanged(this.tabs.getActive(),null,this.tabs);this.canvas=new o(t.findChild(i,{tagName:"CANVAS",attribute:{"data-bx-canvas":"canvas"}},true));this.preview=new r(t.findChild(i,{tagName:"CANVAS",attribute:{"data-bx-canvas":"preview"}},true));t.addCustomEvent(this.canvas,"onChangeCanvas",t.proxy(this.preview.set,this.preview));t.addCustomEvent(this.canvas,"onChangeCanvasArea",t.proxy(this.preview.position,this.preview));t.addCustomEvent(this.canvas,"onResetCanvas",t.proxy(this.preview.reset,this.preview));t.addCustomEvent(this.canvas,"onErrorCanvas",t.proxy(function(a,i){var s=this.tabs;t.addClass(s.tabs["canvas"]["body"],"errored");var e=t.findChild(s.tabs["canvas"]["body"],{attribute:{"data-bx-role":"tab-canvas-error"}},true);e.innerHTML=a},this));var n=t.findChild(i,{attribute:{"data-bx-role":"canvas-button"}},true);if(n){t.bind(n,"click",function(){if(this.canvas.canvasIsSet===true){this.tabs.show("canvas")}}.bind(this));t.addCustomEvent(this.canvas,"onChangeCanvas",function(){t.addClass(n,"active")}.bind(this));t.addCustomEvent(this.canvas,"onResetCanvas",function(){t.removeClass(n,"active")}.bind(this))}var h=t.findChild(i,{attribute:{"data-bx-role":"try-again-button"}},true);if(h){t.bind(h,"click",t.proxy(function(){this.canvas.reset();this.tabs.showPrevious()},this))}var l=t.findChild(i,{attr:{"data-bx-role":"camera-button"}},true);if(l){l.onclick=t.delegate(function(a){if(this.canvas)this.canvas.set(e);this.tabs.show("canvas","camera");return t.PreventDefault(a)},this)}var p=t.findChild(i,{attr:{"data-bx-role":"zoom-knob"}},true),d=t.findChild(i,{attr:{"data-bx-role":"zoom-scale"}},true),c=t.findChild(i,{attr:{"data-bx-role":"zoom-plus-button"}},true),m=t.findChild(i,{attr:{"data-bx-role":"zoom-minus-button"}},true);if(p&&d&&c&&m){var u=t.findChild(i,{tagName:"DIV",className:"main-file-input-control"},true),v=new s({scale:d,knob:p,plus:c,minus:m});t.addCustomEvent(v,"onChangeSize",t.proxy(function(t){this.canvas.scale(t)},this));t.addCustomEvent(this.canvas,"onChangeCanvas",t.proxy(function(a,i){if(i.left>=0&&i.top>=0)t.hide(u);else t.show(u);this.reset()},v))}var f=t.findChild(i,{tagName:"INPUT",attr:{type:"file","data-bx-role":"file-button"}},true);if(f){var b=t.delegate(function(a){t.PreventDefault(a);var i,s=t.findChild(t(this.id),{tagName:"INPUT",attr:{type:"file","data-bx-role":"file-button"}},true);if(a&&a.target)i=a.target.files;else if(a&&t(s))i=s.files;this.addFiles(i);if(!t(s))return;t.unbindAll(s);var e=s.cloneNode(true,{value:""});t.adjust(e,{props:{value:""},attrs:{value:""}});e.setAttribute("new","Y"+(new Date).valueOf());s.parentNode.insertBefore(e,s);s.parentNode.removeChild(s);t.bind(e,"change",b)},this);t.bind(f,"change",b);h=t.findChild(i,{attribute:{"data-bx-role":"tab-file-body"}},true);if(t.DD&&t.type.isDomNode(h)&&h.parentNode){var g=new t.DD.dropFiles(i);if(g&&g.supported()&&t.ajax.FormData.isSupported()){g.f={dropFiles:t.delegate(function(t,a){if(a&&a["dataTransfer"]&&a["dataTransfer"]["items"]&&a["dataTransfer"]["items"].length>0){var i=a["dataTransfer"],s,e,n=[],o=false;for(s=0;s<i["items"].length;s++){if(i["items"][s]["webkitGetAsEntry"]&&i["items"][s]["getAsFile"]){o=true;e=i["items"][s]["webkitGetAsEntry"]();if(e&&e.isFile){n.push(i["items"][s]["getAsFile"]())}}}if(o)t=n}this.addFiles(t)},this),dragEnter:t.proxy(function(a){var i=false;if(a&&a["dataTransfer"]&&a.dataTransfer.types!=null&&a.dataTransfer.items!=null){var s=false,e;for(e=0;e<a.dataTransfer.types.length;e++){if(a.dataTransfer.types[e]=="Files"){s=true;break}}if(s){for(e=0;e<a.dataTransfer.items.length;e++){if(a.dataTransfer.items[e].type.indexOf("image/")==0){i=true;break}}}}if(i){this.tabs.show("file");t.addClass(h,"dnd-over")}},this),dragLeave:function(){t.removeClass(h,"dnd-over")}};t.addCustomEvent(g,"dropFiles",g.f.dropFiles);t.addCustomEvent(g,"dragEnter",g.f.dragEnter);t.addCustomEvent(g,"dragLeave",g.f.dragLeave)}}}t.onCustomEvent(this,"onEditorHasBeenShown",[this])},show:function(a){if(this.popup===null){var i=t.create("DIV",{attrs:{id:this.id},style:{display:"none"},html:this.getTemplate()});this.popup=t.PopupWindowManager.create("popup"+this.id,null,{className:"main-file-input-popup",autoHide:false,lightShadow:true,closeIcon:true,closeByEsc:true,titleBar:t.message("JS_AVATAR_EDITOR_TITLE_BAR"),content:i,zIndex:t.PopupWindowManager.getMaxZIndex()+1,overlay:{},events:{onPopupShow:this.handlers.onPopupShow,onAfterPopupShow:this.handlers.onAfterPopupShow,onPopupClose:this.handlers.onPopupClose},buttons:[new t.PopupWindowButton({text:t.message("JS_AVATAR_EDITOR_SAVE_BUTTON"),className:"popup-window-button-accept",events:{click:this.handlers.apply}}),new t.PopupWindowButtonLink({text:t.message("JS_AVATAR_EDITOR_CANCEL_BUTTON"),className:"popup-window-button-link-cancel",events:{click:this.handlers.cancel}})]})}else{t.onCustomEvent(this,"onEditorHasBeenShown",[this])}if(a==="camera"||a==="file"){var s=t.proxy(function(){this.tabs.show(a)},this);if(this.popup.isShown())s();else t.addCustomEvent(this,"onEditorHasBeenShown",s)}this.popup.show();this.popup.adjustPosition()},showFile:function(a){t.addCustomEvent(this,"onEditorHasBeenShown",t.proxy(function(){this.tabs.show("file");this.tabs.show("canvas","file");this.canvas.load(a)},this));this.show()},click:function(){this.show()},apply:function(){var a=this.canvas.pack();if(a!==null){t.onCustomEvent(this,"onApply",[a,this.canvas.canvas]);this.popup.close()}else{this.cancel()}},cancel:function(){this.popup.close()},onPopupShow:function(){},onAfterPopupShow:function(){try{this.bindTemplate()}catch(a){this["bindTemplateCounter"]=(this["bindTemplateCounter"]||0)+1;if(this["bindTemplateCounter"]<10){setTimeout(t.proxy(this.onAfterPopupShow,this),500)}}},onPopupClose:function(){if(this.tabs)t.onCustomEvent(this.tabs,"onTabHasBeenChanged",[null,null,this.tabs]);t.removeCustomEvent(this.popup,"onPopupShow",this.handlers.onPopupShow);t.removeCustomEvent(this.popup,"onAfterPopupShow",this.handlers.onAfterPopupShow);t.removeCustomEvent(this.popup,"onPopupClose",this.handlers.onPopupClose);this.popup.destroy();this.popup=null}};return n}()})();
//# sourceMappingURL=core_avatar_editor.map.js